Skip to content

Loadpoint UI: time-based values instead of session values for integrated devices (BC) - #35525

Merged
naltatis merged 5 commits into
masterfrom
ui/integrated-device-period-stats
Nov 12, 2026
Merged

naltatis merged 5 commits into
masterfrom
ui/integrated-device-period-stats

Conversation

@naltatis

@naltatis naltatis commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

fixes #35454, refs #19753

Session values mislead for heaters. The card now also offers the rolling 24h and 7d windows, attributed like the Energy page, so both views agree.

  • Integrated devices show no session values, their dropdown holds the periods only.
  • Loadpoints publish last24h and last7d: energy, pv energy, battery energy, average price, cost. Grid is the rest. todayEnergy unchanged.
  • Period entries show a "Solar" share like the session, which includes the battery.
  • Period values show from the start, prices need a grid tariff.
  • Grouped dropdown: Session, Last 24h, Last 7 days.
  • Period entries read "Charged (24h)" for vehicles, "Consumed (24h)" for heaters.
  • Old flat 24h and 7d energy entries move into the period groups.
  • CustomSelect supports optgroups via a group field on the option.
  • Breaking: last24hEnergy and last7dEnergy are replaced by the last24h and last7d objects, in the state API and on MQTT.

Screenshots

CleanShot 2026-11-12 at 15 53 05@2x CleanShot 2026-11-12 at 15 53 11@2x CleanShot 2026-11-12 at 15 53 23@2x CleanShot 2026-11-12 at 15 53 29@2x

Published loadpoint data, excerpt:

   "todayEnergy": 24200,
-  "last24hEnergy": 31500,
-  "last7dEnergy": 182300,
+  "last24h": {
+    "energy": 31500,
+    "pvEnergy": 9800,
+    "batteryEnergy": 3460,
+    "pricePerKWh": 0.231,
+    "price": 7.28
+  },
+  "last7d": {
+    "energy": 182300,
+    "pvEnergy": 88400,
+    "batteryEnergy": 18600,
+    "pricePerKWh": 0.196,
+    "price": 35.73
+  }

Follow-ups: remove integrated devices from the charging sessions log, clarify the "Solar" naming (pv and battery are already published separately).

🤖 Generated with Claude Code

@github-actions github-actions Bot added enhancement New feature or request ux User experience/ interface heating Heating labels Oct 28, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 4 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="core/metrics/db_flow.go" line_range="384" />
<code_context>
 		res.Co2 = &co2
 	}

+	res.entities = entities
 	return res, nil
 }
</code_context>
<issue_to_address>
**Loadpoint cards show combined usage**

When two loadpoints in the same group have the same configured title, `QueryFlow` maps both loadpoint IDs to a shared `flowEntity`, so `periodStats` returns combined meters, energy, autarky, and prices for each loadpoint; both cards show the combined values as their own.

Keep flow attribution separate by loadpoint ID instead of sharing a title-aggregated entity.

Also at `core/metrics/db_flow.go:177`, `core/metrics/stats.go:47-49`.
</issue_to_address>

### Comment 2
<location path="core/metrics/stats.go" line_range="65" />
<code_context>
 	res := EnergyStats{slot: slotStart}

-	sqlDB, err := db.Instance.DB()
+	today, err := periodStats(entity, midnight, slotStart)
 	if err != nil {
 		return res, err
</code_context>
<issue_to_address>
**Period attribution stays stale**

When the loadpoint collector computes stats at a slot boundary before other collectors have persisted their completed-slot readings, `energyStats` calls `periodStats` before other collectors have persisted their completed-slot readings, so `QueryFlow` caches incomplete attribution for that slot; later readings do not trigger a refresh, and the published autarky and price values remain wrong until the next slot.

Compute and cache period stats from a consistent snapshot after the slot’s collector writes complete, or invalidate the cached stats when those writes land.
</issue_to_address>

### Comment 3
<location path="core/metrics/stats.go" line_range="71-75" />
<code_context>
-	).Scan(&res.Today, &res.Last24h, &res.Last7d)
-
-	return res, err
+	if res.Last24h, err = periodStats(entity, slotStart.Add(-24*time.Hour), slotStart); err != nil {
+		return res, err
+	}
+	if res.Last7d, err = periodStats(entity, slotStart.AddDate(0, 0, -7), slotStart); err != nil {
</code_context>
<issue_to_address>
**Stats refreshes repeat database scans**

When multiple loadpoints refresh their stats, especially with a large meter history, `energyStats` calls `periodStats` for today, 24 hours, and 7 days, and each call runs `QueryFlow` over meter, sink, and flow data. Repeating those scans for each loadpoint increases database load and delays stats updates.

Reuse flow attribution across the period calculations and loadpoints instead of rerunning `QueryFlow` for every period.
</issue_to_address>

### Comment 4
<location path="assets/js/components/Loadpoints/SessionInfo.vue" line_range="133-134" />
<code_context>
+		options(): Option[] {
+			const periods = this.experimental ? this.periodOptions : [];
+			// integrated devices drop the session once periods replace it
+			const session =
+				this.chargerFeatureIntegratedDevice && periods.length ? [] : this.sessionOptions;
+			return [...session, ...periods].filter((option) => option.available);
 		},
</code_context>
<issue_to_address>
**Integrated devices retain session values**

When the device is integrated and experimental mode is off, or no period stats are available, `periods.length` is false, so `session` remains `this.sessionOptions` and the dropdown keeps session values; the card displays misleading session data.

Suppress `sessionOptions` for integrated devices regardless of whether period options are available.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread core/metrics/db_flow.go Resolved
Comment thread core/metrics/stats.go Resolved
Comment thread core/metrics/stats.go Resolved
@Tombra1889

Copy link
Copy Markdown
Contributor

Damit würden dann auch keine Charging Sessions mehr erzeugt werden, oder?
image

@naltatis

Copy link
Copy Markdown
Member Author

Damit würden dann auch keine Charging Sessions mehr erzeugt werden, oder?

Ja, da arbeiten wir ja schon länger drauf hin 😆. Neue Energy-Seite und so ...

Aber noch nicht in diesem PR. Followup Thema.

@florian240483

Copy link
Copy Markdown

@naltatis Ist Autarkie für einzelne Verbraucher/Ladepunkte wirklich der treffendere Begriff oder sollte man lieber bei PV-Anteil bleiben? Ich würde den Begriff Autarkie nur in Bezug auf Gesamtverbrauch von Site sehen.

@naltatis

Copy link
Copy Markdown
Member Author

Ist vor dem Hintergrund zu #33251.
Bislang behandeln wir ja Batterie und PV Energie als beide als "Eigenenergie". Auf der Energie-Seite weise wir jetzt alle drei Typen (PV, Batterie, Netz) separat aus. Das ist, im Vergleich zur Ladesession, wo wir noch das "alte Modell" haben ein bisschen ein Bruch. Technisch korrekt wäre hier "PV + Batterie". Wir könnten alternativ auf "Netzanteil" anzeigen, das ist aber die unschönere Zahl 😆. Lieber "mehr vom Guten" als "weniger vom Schlechten".

Ich bin aber offen für alternatives Wording oder klarere Beschreibung hier.

@Tombra1889

Copy link
Copy Markdown
Contributor

Eigentlich müsste nur die Autarkiequote an der Batterie gespeichert werden und sich dann vererben. Dann wäre es auch bzgl. Netzladen korrekt.

@florian240483

florian240483 commented Nov 5, 2026 •

Copy link
Copy Markdown

Eigentlich müsste nur die Autarkiequote an der Batterie gespeichert werden und sich dann vererben. Dann wäre es auch bzgl. Netzladen korrekt.

Stimmt, das wäre eine gute Idee. Das bedeutet die Hausbatterie braucht eine Autarkiequote, wieviel Netzenergie und Pv-Energie gespeichert ist. Wenn ein Ladepunkt dann Energie aus der Batterie bekommt, geht nur die geladene Energiemenge x Autarkie(Batterie) in den Pv-Anteil des Ladepunktes mit ein.

Damit könnte man dann beim Wording PV-Anteil bleiben. Der PV-Anteil des Ladepunktes setzt sich dann aus Direktverbrauch + PV-Anteil der Batterieenergie zusammen.

@sourcery-ai

sourcery-ai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Linked issues

Checked at commit aa52d2d

#35454 Misleading PV indicator for heatpump · 1 of 1 met

# Requirement Status Notes
1 Avoid showing an integrated device’s session PV share as if it represented energy use over a longer period. ✅ Met Integrated devices omit session values and offer rolling 24-hour and 7-day period values; the period solar percentage is derived from attributed PV and battery energy.

@naltatis naltatis changed the title Loadpoint UI: time-based values instead of session values for integrated devices Loadpoint UI: time-based values instead of session values for integrated devices (BC) Nov 12, 2026
@naltatis

Copy link
Copy Markdown
Member Author

@florian240483 @Tombra1889 tried different "Autarky" alternatives. "Solar & battery (24h)" is the most descriptive and technically correct one. "Solar share", "Self-supply", "Own energy", "Self-produced" are also valid alternatives. But for now, I'd say we skip this discussion here and and go with the existing "Solar" wording we already have for sessions. Needs a proper rename/cleanup later in all places.

@naltatis
naltatis merged commit 94fad41 into master Nov 12, 2026
15 checks passed
@naltatis
naltatis deleted the ui/integrated-device-period-stats branch November 12, 2026 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request heating Heating ux User experience/ interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Misleading PV indicator for heatpump

3 participants